package com.igbeok.miscellaneous.hibernate.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.validator.constraints.NotEmpty;

@Entity
@Table(name = "TROLE", schema = "GUI")
public class TRole implements Serializable {

	private static final long serialVersionUID = 276476259318242156L;

	private Long id;
	private String roleName;
	//private List<TPrivilege> privileges = new ArrayList<TPrivilege>();

	@Id
	@Column(name = "ID", unique = true, nullable = false, precision = 16, scale = 0)
	@GenericGenerator(name = "troleIdGen", strategy = "sequence", parameters = { @Parameter(name = "sequence", value = "TROLE_SEQ") })
	@GeneratedValue(generator = "troleIdGen")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@NotEmpty
	@Column(name = "ROLE_NAME", length = 30)
	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
/*
	@ManyToMany(targetEntity = TPrivilege.class, cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@JoinTable(name = "TROLE_PRIV", joinColumns = @JoinColumn(name = "ROLE_ID"), inverseJoinColumns = @JoinColumn(name = "RPIVILEGE_ID"))
	public List<TPrivilege> getPrivileges() {
		return privileges;
	}

	public void setPrivileges(List<TPrivilege> privileges) {
		this.privileges = privileges;
	}*/

}
